package com.cqcvc.mapper;

import com.cqcvc.pojo.DownLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DownLogMapper {
    /**
     * 记录下载日志
     * @param title
     * @param author
     * @return
     */
    @Insert("insert into downlog(title,author) values(#{title},#{author})")
    public int insert(@Param("title") String title, @Param("author") String author);

    /**
     * 统计每个文档的下载次数
     * @return
     */
    @Select("SELECT title,COUNT(*) as num FROM downlog GROUP BY title ORDER BY num DESC LIMIT 5")
    public List<DownLog> stas();
}
